<template>
  <div>
    <el-form ref="Goods" label-width="120px">
      <el-form-item label="商品名">
        <el-input v-model="Goods.goodsName"></el-input>
      </el-form-item>
      <el-form-item label="商品品类">
        <el-input v-model="Goods.goodsType"></el-input>
      </el-form-item>
      <el-form-item label="商品材质">
        <el-input v-model="Goods.goodsMaterial"></el-input>
      </el-form-item>
      <el-form-item label="商品适用规格">
        <el-input v-model="Goods.goodsDogtype"></el-input>
      </el-form-item>
      <el-form-item label="商品专属规格">
        <el-input v-model="Goods.goodsExdogtype"></el-input>
      </el-form-item>
      <el-form-item label="商品包装规格">
        <el-input v-model="Goods.goodsPackage"></el-input>
      </el-form-item>
      <el-form-item label="商品口味">
        <el-input v-model="Goods.goodsFlavor"></el-input>
      </el-form-item>
      <el-form-item label="商品特殊作用">
        <el-input v-model="Goods.goodsFunction"></el-input>
      </el-form-item>
      <el-form-item label="商品产地">
        <el-input v-model="Goods.goodsPlace"></el-input>
      </el-form-item>
      <el-form-item label="商品生产日期">
        <el-input v-model="Goods.goodsDate"></el-input>
      </el-form-item>
      <el-form-item label="商品保质期">
        <el-input v-model="Goods.goodsLasting"></el-input>
      </el-form-item>
      <el-form-item label="商品特色说明">
        <el-input v-model="Goods.goodsFeature"></el-input>
      </el-form-item>
      <el-form-item label="商品价格">
        <el-input v-model="Goods.goodsPrice"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确定</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { updateGoods } from "@/services/GoodsService.js";
import { selectById } from "@/services/GoodsService.js";

export default {
  data() {
    return {
      Goods: {
        goodsId: "",
        goodsName: "",
        goodsType: "",
        goodsMaterial: "",
        goodsDogtype: "",
        goodsExdogtype: "",
        goodsPackage: "",
        goodsFlavor: "",
        goodsFunction: "",
        goodsPlace: "",
        goodsDate: "",
        goodsLasting: "",
        goodsFeature: "",
        goodsPrice: "",
        goodsPic: "",
      },
    };
  },
  methods: {
    async onSubmit() {
      var resp = await updateGoods(this.Goods, this.$route.params.goodsId);
      if (resp == true) {
        console.log("修改成功");
        this.$router.push({ name: "Goods" });
      } else {
        console.log("修改失败");
      }
    },
  },

  async created() {
    console.log("---------");
    console.log(this.$route.params.goodsId);
    var resp1 = await selectById(this.$route.params.goodsId);
    this.Goods = resp1;
    console.log(this.Goods);
  },
};
</script>

    

<style>
</style>